package com.whu.waterworks.action;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.opensymphony.xwork2.ActionSupport;
import com.whu.waterworks.model.Stationnumposition;
import com.whu.waterworks.model.WaterPlant;
import com.whu.waterworks.service.StationnumpositionService;
import com.whu.waterworks.service.WaterPlantService;

public class SafetyMonitorInit extends ActionSupport{
	private static final long serialVersionUID = -3095814458621334925L;
	private WaterPlantService waterPlantService;
	private StationnumpositionService stationnumpositionService;
	private List<WaterPlant> waterPlants=new ArrayList<WaterPlant>();
	private List<Stationnumposition> stationnumpositions =new ArrayList<>();
	private Map<String, List<Stationnumposition>> map=new HashMap<>();
	
	@Override
	public String execute() throws Exception {
		waterPlants=waterPlantService.getAllWaterPlants();
		for (WaterPlant waterPlant : waterPlants) {
			map.put(waterPlant.getWaterPlantName(), stationnumpositionService.findAll(waterPlant.getWaterPlantCode()));
		}
		System.out.println("waterPlants size:"+waterPlantService.getAllWaterPlants().size());
		System.out.println("map:"+map.toString());
		return super.execute();
	}

	public WaterPlantService getWaterPlantService() {
		return waterPlantService;
	}

	public void setWaterPlantService(WaterPlantService waterPlantService) {
		this.waterPlantService = waterPlantService;
	}

	public StationnumpositionService getStationnumpositionService() {
		return stationnumpositionService;
	}

	public void setStationnumpositionService(
			StationnumpositionService stationnumpositionService) {
		this.stationnumpositionService = stationnumpositionService;
	}

	public static long getSerialversionuid() {
		return serialVersionUID;
	}

	public List<WaterPlant> getWaterPlants() {
		return waterPlants;
	}

	public void setWaterPlants(List<WaterPlant> waterPlants) {
		this.waterPlants = waterPlants;
	}

	public List<Stationnumposition> getStationnumpositions() {
		return stationnumpositions;
	}

	public void setStationnumpositions(List<Stationnumposition> stationnumpositions) {
		this.stationnumpositions = stationnumpositions;
	}

	public Map<String, List<Stationnumposition>> getMap() {
		return map;
	}

	public void setMap(Map<String, List<Stationnumposition>> map) {
		this.map = map;
	}


}
